from sqlalchemy import Column, Integer, String, Boolean
from sqlalchemy.orm import relationship

from app.db.base import Base

class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, index=True)
    username = Column(String, unique=True, index=True, nullable=False)
    email = Column(String, unique=True, index=True, nullable=False)
    password_hash = Column(String, nullable=False)
    is_active = Column(Boolean, default=True) # For email verification status/ soft delete
    is_admin = Column(Boolean, default=False)

    # Relationships (will be defined later)
    credits = relationship("Credit", back_populates="user", uselist=False, cascade="all, delete-orphan")
    image_history = relationship("ImageHistory", back_populates="user")
    gallery_uploads = relationship("Gallery", back_populates="uploader")
    # gallery_uploads = relationship("Gallery", back_populates="uploader")
